/*
 * linked_list.h
 *
 *  Created on: 2019��9��21��
 *      Author: Administrator
 */

#include <stdbool.h>
#ifndef LINKED_LIST_H_
#define LINKED_LIST_H_

typedef struct Node{
	int value;
	struct Node* next;
} Node;


typedef struct LinkedList{
	struct Node *head;    // ͷ�ڵ�
	int length;           // ������
} LinkedList;

LinkedList* init_linked_list();

void create(LinkedList* list, int array[], int length);

int list_length(LinkedList *list);

bool is_empty(LinkedList *list);

/**
 * 头插法
 */
bool insert_at_head(LinkedList *list, int value);

/**
 * 尾插法
 */
bool insert_at_tail(LinkedList *list, int value);

/**
 * 头删法
 */
bool delete_at_head(LinkedList *list);

/**
 * 尾删法
 */
bool delete_at_tail(LinkedList *list);

/**
 * ��indexλ�ò���Ԫ��
 */
bool insert(LinkedList *list, int index, int value);

/**
 * ��indexλ��ɾ��Ԫ��
 */
bool delete(LinkedList *list, int index);

/**
 * ��������Ų���
 * ������ index Ҫ����Ԫ�ص����  (1<=index<=length)
 * ���أ���Ԫ�ص�ֵ
 */
int search_by_index(LinkedList *list, int index);

/**
 * ������ֵ����
 * ���أ�����ҵ�������Ԫ����ţ����򷵻�NOT_FOUND 0
 */
int search_by_value(LinkedList* list, int value);

/**
 * ��ӡ����Ԫ��ֵ
 */
void print_linked_list(LinkedList *list);


#endif /* LINKED_LIST_H_ */
